package com.hgyc.mom.wms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hgyc.mom.wms.entity.ScmPurchaseDetail;
import com.hgyc.mom.wms.mapper.ScmPurchaseDetailMapper;
import com.hgyc.mom.wms.service.ScmPurchaseDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 采购明细Service业务层实现
 *
 * @author fwj
 * @since 2025-05-15
 */
@Slf4j
@Service
public class ScmPurchaseDetailServiceImpl extends ServiceImpl<ScmPurchaseDetailMapper, ScmPurchaseDetail> implements ScmPurchaseDetailService {

    @Override
    public List<ScmPurchaseDetail> getByParentId(Long parentId) {
        LambdaQueryWrapper<ScmPurchaseDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ScmPurchaseDetail::getPurchaseId, parentId);
        return list(wrapper);
    }

    @Override
    public void deleteByParentId(Long parentId) {
        LambdaQueryWrapper<ScmPurchaseDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ScmPurchaseDetail::getPurchaseId, parentId);
        remove(wrapper);
    }

    @Override
    public void deleteBatchByParentIds(List<Long> parentIds) {
        LambdaQueryWrapper<ScmPurchaseDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(ScmPurchaseDetail::getPurchaseId, parentIds);
        remove(wrapper);
    }
}